package org.ingeniart.siec.controller;

import javax.annotation.PostConstruct;
import javax.enterprise.inject.Model;
import javax.enterprise.inject.Produces;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import org.ingeniart.siec.model.TipoDocumento;
import org.ingeniart.siec.service.TipoDocumentoRegistration;

@Model
public class TipoDocumentoController_b {

	@Inject
	private FacesContext facesContext;
	
	@Inject
	private TipoDocumentoRegistration tipoDocumentoRegistration;
	private TipoDocumento newTipoDocumento;
	
	@Named
	@Produces
	public TipoDocumento getNewTipoDocumento() {
		return newTipoDocumento;
	}
	
	public void register()throws Exception
	{
		tipoDocumentoRegistration.register(newTipoDocumento);
		facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Registered!", "Registration successful"));
	    initNewTipoDocumento();
	}
	
	@PostConstruct
	public void initNewTipoDocumento(){
		newTipoDocumento = new TipoDocumento();
	}
	
	
	
	
}
